package com.wxq.workpad.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.wxq.workpad.R
import com.wxq.workpad.entity.LaiLiaoItemEntity

/**
 * @Description: 类作用描述
 */
class LaiLiaoListAdapterOld(context: Context):RecyclerView.Adapter<RecyclerView.ViewHolder>() {
    private var mContext:Context

    private var mData:MutableList<LaiLiaoItemEntity>

    private lateinit var listener:(position:Int)->Unit

    init {
        mContext=context
        mData= mutableListOf()
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return ItemHold(LayoutInflater.from(mContext).inflate(R.layout.item_lailiao,parent,false))
    }

    override fun getItemCount(): Int {
        if (mData==null){
            return 0;
        }
        return mData.size
    }

    fun updateDate(data:MutableList<LaiLiaoItemEntity>){
         mData=data
        notifyDataSetChanged()
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        if (holder is ItemHold){
            val item = mData.get(position)
//            holder.tv_test.setOnClickListener {
//                listener(position)
//            }
//            holder.attr1.setText(mData.get(position).supplierName)
//            if (mData.get(position).status.equals("2")){
////                status=0 待检 status =2 已检
//                Glide.with(mContext).load( R.mipmap.hasdeal).into(holder.iv_state)
//            }else{
//                Glide.with(mContext).load( R.mipmap.waitdeal).into(holder.iv_state)
//            }
            holder.attr1.text=item.asnNo
            holder.attr2.text=item.asnRowNo
            holder.attr3.text=item.asnNo
            holder.attr4.text=item.asnNo
            holder.attr5.text=item.asnNo
            holder.attr6.text=item.asnNo

        }
    }




    fun setClickListener(itemClick:(position:Int)->Unit){
        listener=itemClick
    }


    inner class ItemHold(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var attr1:TextView
        var attr2:TextView
        var attr3:TextView
        var attr4:TextView
        var attr5:TextView
        var attr6:TextView
//        var attr1:TextView
//        var iv_state:ImageView

        init {
            attr1=itemView.findViewById(R.id.attr1)
            attr2=itemView.findViewById(R.id.attr2)
            attr3=itemView.findViewById(R.id.attr3)
            attr4=itemView.findViewById(R.id.attr4)
            attr5=itemView.findViewById(R.id.attr5)
            attr6=itemView.findViewById(R.id.attr6)
//            attr1=itemView.findViewById(R.id.attr1)
//            iv_state=itemView.findViewById(R.id.iv_state)

        }
    }
}